<%--
  Created by IntelliJ IDEA.
  User: FT
  Date: 2020/9/22
  Time: 15:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>菜单</title>
    <style>
        #top {
            border: 1px red solid;
            height: 10%;
        }

        #left {
            /*margin-top: 5px;*/
            float: left;
            border: 1px red solid;
            width: 15%;
            height: 88%;
        }

        #right {
            /*margin-top: 5px;*/
            margin-left: 10px;
            float: left;
            border: 1px red solid;
            width: 84%;
            height: 88%;
        }
    </style>
    <script>
        $(function () {
            $.ajax({
                url: "${pageContext.request.contextPath}/menu/getMenu",
                type: "post",
                data: "",
                dataType: "json",
                success: function (data) {
                    // alert(data)
                    console.log(data);
                    var parentList = data.parentList;
                    var sonList = data.sonList;
                    // console.log(parentList[1].id);
                    // console.log(sonList[1].parentId);
                    var html = "";
                    for (var i = 0; i < parentList.length; i++) {
                        html += parentList[i].name + '<ul>';
                        for (var j = 0; j < sonList.length; j++) {
                            if (parentList[i].id == sonList[j].parentId) {
                                html += '<li><a href="${pageContext.request.contextPath}' + sonList[j].url + '">' + sonList[j].name + '</a></li>';
                            }
                        }
                        html += '</ul>';
                    }
                    $("#left").append(html)
                }
            });
        });
    </script>
</head>
<body>
<div id="left">
   <%-- 用户管理
    <ul>
        <li><a href="${pageContext.request.contextPath}/user/list">添加用户</a></li>
        <li><a href="#">删除用户</a></li>
    </ul>
    客户信息
    <ul>
        <li><a href="#">添加客户</a></li>
        <li><a href="#">删除客户</a></li>
    </ul>--%>
</div>
</body>
</html>
